function previewFile(ftpPathName) {
    //var url = [[${@util.getPreviewUrl(ftpPathName)}]];
    var url = $.operate.getPreviewUrl(ftpPathName);
    if (url) {
        var fileSuffix = ftpPathName.substring(ftpPathName.lastIndexOf(".") + 1);
        fileSuffix = fileSuffix.toLowerCase();
        if ("mp4" == fileSuffix) {
            window.open(ctx + "showVideo.html?url=" + url, 'newwindow', 'height=1000, width=1000, top=0, left=0, ' +
                'toolbar=no, menubar=no, scrollbars=yes, resizable=no,  status=no');
        } else if ("bmp" == fileSuffix || "gif" == fileSuffix ||
            "jpg" == fileSuffix || "jpeg" == fileSuffix || "png" == fileSuffix || "pdf" == fileSuffix) {
            window.open(url, 'newwindow', 'height=1000, width=1000, top=0, left=0, ' +
                'toolbar=no, menubar=no, scrollbars=yes, resizable=no,  status=no');
        } else {
            $.ajax({
                type: "GET",
                url: url,
                cache: false,
                async: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function (result) {
                    window.open(result.url, 'newwindow', 'height=1000, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=no,  status=no');
                    //$.modal.open("预览", result.url, "500px", "800px");
                },
                error: function (error) {
                    $.modal.alertWarning("预览失败。");
                }
            });
        }
    } else {
        $.modal.alertWarning("该格式文件不支持预览！");
    }
}

function downloadFile(ftpPathName, fileName) {
    window.location.href = ctx + "common/ftpDownload?ftpPathName=" + ftpPathName + "&fileName=" + fileName;
}

function downloadFileById(fileId){
    window.location.href = ctx + "common/attachment/download/" + fileId;
}
